//
//  CommonSmallViewCell.m
//  TeamInformatization
//
//  Created by bigger on 2019/4/2.
//  Copyright © 2019年 SPIC. All rights reserved.
//

#import "CommonSmallViewCell.h"

@interface CommonSmallViewCell ()

// 信息标题
@property (nonatomic, strong) SimpleLabel *messageTitle;
// 日期
@property (nonatomic, strong) SimpleLabel *messageDate;
// 时长
@property (nonatomic, strong) SimpleLabel *messageDuration;

@end


@implementation CommonSmallViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCellView];
        
        self.backgroundColor = [UIColor whiteColor];
        // 取消cell选中状态
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)creatCellView
{
    UIView *pointView = [[UIView alloc] init];
    pointView.backgroundColor = kCommonRedColor;
    [self addSubview:pointView];
    [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10 * kScaleWidth);
        make.centerY.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(8 * kScaleWidth, 8 * kScaleWidth));
    }];
    pointView.layer.masksToBounds = YES;
    pointView.layer.cornerRadius = 4. * kScaleWidth;
    pointView.layer.shouldRasterize = YES; //圆角缓存
    pointView.layer.rasterizationScale = [UIScreen mainScreen].scale;// 抗锯齿边缘
    
    self.messageTitle = [SimpleLabel initWithText:@"" TextColor:kTitleTextColor TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 15] TextAlignment:NSTextAlignmentLeft];
    [self addSubview:_messageTitle];
    [_messageTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(pointView.mas_right).offset(10 * kScaleWidth);
        make.centerY.mas_equalTo(self);
    }];
    
    UIImageView *arrowIamge = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"箭头"]];
    [self addSubview:arrowIamge];
    [arrowIamge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(-10 * kScaleWidth);
    }];
    
    self.messageDuration = [SimpleLabel initWithText:@"" TextColor:kSubTitleTextColor TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 13] TextAlignment:NSTextAlignmentRight];
    [self addSubview:_messageDuration];
    [_messageDuration mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(arrowIamge.mas_left).offset(-5 * kScaleWidth);
        make.centerY.mas_equalTo(self);
    }];
    
    self.messageDate = [SimpleLabel initWithText:@"" TextColor:kSubTitleTextColor TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 13] TextAlignment:NSTextAlignmentRight];
    [self addSubview:_messageDate];
    [_messageDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.messageDuration.mas_left).offset(-10 * kScaleWidth);
        make.centerY.mas_equalTo(self);
    }];
    
    // 分割线
    UILabel *lineLabel = [[UILabel alloc] init];
    lineLabel.backgroundColor = kCuttingLineColor;
    [self addSubview:lineLabel];
    [lineLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
}

- (void)setShowCellWithLearnMessage:(LearnMessage *)learnMessage
{
    _messageTitle.text = learnMessage.title;
    _messageDate.text = learnMessage.date;
    _messageDuration.text = learnMessage.durtain;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
